#ifndef PSD_BACKEND_H
#define PSD_BACKEND_H

#include "psd_backend_session.h"
#include "psd_settings.h"

enum psd_freeze_type_t { HARD_FREEZE, SOFT_FREEZE };

/*
 * int psd_session_start(const char *session_id, psdSettings *settings);
 *     This function allocates and registers a new session with the associated
 *     session id and settings. The session starts out in a HARD_FREEZE state
 *     since it is doing nothing in particular at that point.
 */
int psd_session_start(const char *session_id, psdSettings *settings);

/*
 * int psd_session_end(const char *session_id);
 *     This function closes down all the connections to, unregisters and frees
 *     the specified session.
 */
int psd_session_end(const char *session_id);

/*
 * int psd_session_add_conn(const char *session_id, const char *connection_id, const char *contact_string, psdSettings *settings);
 *    This function adds a new child connection for the session to the host
 *    specified in "contact_string" using the given settings. If the session is
 *    not hard frozen, the function returns with an error.
 */
int psd_session_add_conn(const char *session_id, const char *connection_id, const char *contact_string, psdSettings *settings);

/*
 * int psd_session_remove_conn(const char *session_id, const char *connection_id);
 *     This function removes the connection to the host specified in the
 *     contact string. If the session is not frozen, the function returns with
 *     an error.
 */
int psd_session_remove_conn(const char *session_id, const char *connection_id);

/*
 * int psd_session_replace_conn(const char *session_id, const char *connection_id, char *contact_string, psdSettings *settings);
 *     This function is a simple wrapper around add_conn and remove_conn that
 *     replaces the specified connection with the new one. If the new
 *     connection cannot be made, the old connection is left as is and the
 *     function returns -1. If the old connection doesn't exist, it functions
 *     simply as "add_conn". If the session is not hard frozen, the function
 *     returns with an error.
 */
int psd_session_replace_conn(const char *session_id, const char *connection_id, char *contact_string, psdSettings *settings);

/*
 * int psd_session_freeze(const char *session_id enum psd_freeze_type_t type):
 *    This function freezes the specified session. There are two ways it can be
 *    frozen as specified by "type". SOFT_FREEZE simply stops the session from
 *    transmitting data. HARD_FREEZE allows you to make major changes to the
 *    session(e.g. remove or change a connection)
 */
int psd_session_freeze(const char *session_id, enum psd_freeze_type_t type);

/*
 * int psd_session_thaw(const char *session_id):
 *    This function thaws the specified session allowing it to begin
 *    transmitting data again.
 */
int psd_session_thaw(const char *session_id);

#endif
